/*
 * Copyright (c) 2020 solidwang. All rights reserved.
 */

package com.solidwang.mybatis.response;

import org.apache.commons.lang.StringUtils;

public class ResponseUtil {

    public static SimpleResult<Object> writeResult(Code code, String message, Object data) {
        if (StringUtils.isNotEmpty(message)) {
            return new SimpleResult<Object>(code.getCode(), message, data);
        } else {
            return new SimpleResult<Object>(code.getCode(), code.getMessage(), data);
        }
    }

    public static SimpleResult<Object> writeResult(Code code, String message) {
        return writeResult(code, message,null);
    }

    public static SimpleResult<Object> writeResult(Code code, Object data) {
        return writeResult(code, null, data);
    }

    public static SimpleResult<Object> writeResult(Code code) {
        return writeResult(code, null);
    }

}
